import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import './index.css'
import '../src/flexble.js'
import React,{ Suspense } from 'react'
import { RouterProvider } from 'react-router-dom'
import router from './router/index.tsx'

// 配置高德地图安全密钥
window._AMapSecurityConfig = {
  securityJsCode: '27b7862b642a13a7fe3da8f3a4555d12',
}

// 加载高德地图脚本
const loadAMap = () => {
  const script = document.createElement('script');
  script.type = 'text/javascript';
  script.src = 'https://webapi.amap.com/maps?v=2.0&key=27b7862b642a13a7fe3da8f3a4555d12&plugin=AMap.Scale,AMap.ToolBar,AMap.Geolocation';
  document.head.appendChild(script);
};

// 确保在应用启动时加载地图
loadAMap();

createRoot(document.getElementById('root')!).render(
  <StrictMode>
    <Suspense fallback={<div>Loading...</div>}>
      <RouterProvider router={router} />
    </Suspense>
  </StrictMode>
)
